<div id="<?php echo sfConfig::get('app_windows_invoice_form_id')?>">
<?php if($documentForm->getObject()->getVoid() == 'N'):?>
<div class="module_title">Edit Customer Invoice for <?php echo $contact->getListName();?></div>
<?php else:?>
<div class="module_title">View Customer Invoice for <?php echo $contact->getListName();?>, INVOICE IS VOID.</div>
<?php endif;?>
<?php echo form_tag_for($invoiceForm,$invoiceForm->getUrl(),array('id'=>'formInvoice',))?>
<?php if($documentForm->hasErrors() || $invoiceForm->hasErrors() || $invoiceAmountsForm->hasErrors()):?>
  <ul class="error_list"><li>Errors on form</ul>
<?php endif;?>
<font color="#FF0000"><?php echo $error_message?></font>
<table>
  <tr>
    <td style="vertical-align:top;">
      <?php echo $documentForm->renderGlobalErrors();?>
      <?php echo $invoiceForm->renderGlobalErrors();?>
      <?php echo $invoiceAmountsForm->renderGlobalErrors();?>
      <?php include_partial('invoice_form',array('documentForm'=>$documentForm,'invoiceForm'=>$invoiceForm,));?>
    </td>
    <td style="vertical-align:top;">
      <div class="separator">Charges</div>
      <div id="gridInvoiceAmounts">
        <?php include_partial('invoice_amount_grid',array('invoiceAmountss'=>$invoiceAmountss,))?>
      </div>
      <?php if($documentForm->getObject()->getVoid() == 'N'):?>
      <div id="formInvoiceAmounts">
        <?php include_partial('invoice_amount_form',array('invoiceAmountsForm'=>$invoiceAmountsForm,))?>
      </div>
      <?php endif;?>
    </td>
  </tr>
</table>
  <?php if($documentForm->getObject()->getVoid() == 'N'):?>
      <div class="form_buttons">
        <input type="submit" value="Save" id="invoiceSaveButton"/> |
        <input type="reset" value="Reset" id="invoiceResetButton"/> |
        <input type="button" value="Void" id="invoiceVoidButton" />
      </div>
  <?php endif;?>
</form>
</div>


<?php if($documentForm->getObject()->getVoid() == 'N'):?>
<script language="javascript">
  $(document).ready(
    function(){
      $("#formInvoice").submit(
        function(){
          invoiceFormSubmit();
          return false;
        }
      );
      invoiceSetupInvoiceAmountsGridSelect();
      invoiceSetupVoidButton(
        <?php echo json_encode(array('invoice_iden'=>$invoiceForm->getObject()->getInvoiceIden(),))?>,
        '<?php echo 'Void invoice# '.$invoiceForm->getObject()->getInvoiceType().'-'.$invoiceForm->getObject()->getInvoiceId().'?'?>'
      );
    }
  );
</script>
<?php endif;?>